<!-- 首页-商户列表组件 -->
<template name="wshoplistcom">
	<view class="shoplist">
		<view class="conList_item" @click="navshopDetail(item.suid)" v-for="(item,index) in shoplistArr" :key="index" >
			<view class="conList_title">
				<view class="title_name">
					<text>{{item.shop_name}}</text>
					<text v-if="item.status" class="title_size" :class="statusColor[item.status]">{{item.statusText}}</text>
				</view>
				<view class="title_id">
					<view class="title_id_uid">
						商户UID:&nbsp&nbsp{{item.uid}}
						<!-- <text style="white-space: nowrap;">商户UID:&nbsp&nbsp</text>
						<input type="text" :value="item.uid" disabled="true" /> -->
					</view>
					<view v-if="item.suid">门店ID:&nbsp&nbsp{{item.suid}}</view>
				</view>
			</view>
			<view class="conList_detail">
				<view class="conList_info" v-if="item.realname">
					<view class="info_title">BD</view>
					<view class="info_Text">{{item.realname}} AID{{item.aid}}</view>
				</view>
				<!-- 联系电话只有待处理门店才有 -->
				<view class="conList_info" v-if="shoptype==3">
					<view class="info_title">联系电话</view>
					<view class="info_Text info_eve_phone" @click="makePhone(item.mobile)">{{item.mobile}}</view>
				</view>
				<view class="conList_info" v-if="item.address">
					<view class="info_title">门店地址</view>
					<view class="info_Text">{{item.address}}</view>
				</view>
				<!-- 只要是公海门店就存在外卖未绑定或支付未绑定的标签 -->
				<view class="conList_info" v-if="shoptype==2">
					<view class="info_tag" v-if="!item.bang.isWaimai">外卖未绑定</view>
					<view class="info_tag" v-if="!item.bang.isPay">支付未绑定</view>
				</view>
			</view>
			<view class="conList_detail conList_detail_waimai" v-if="shoptype==3">
				<view class="conList_info">
					<view class="info_title">下发时长</view>
					<view class="info_Text">{{item.distancetime}}</view>
				</view>
				<view class="conList_info" v-if="item.isovertime == true">
					<view class="info_warn">已超时请尽快协助商户完成认证！</view>
				</view>
				<view class="conList_info conList_info_btn" v-if="item.status!=3">
					<view>
						<button type="primary" @click.native.stop="disMerchantver(item)">协助报件</button>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { assistauthscan,getbaseinfo } from '../../api/index.js'
	import { getAuthinfo } from '../../api/indexGet.js'
	import Request from '../../lib/Request'
	export default {
		name: "wshoplistcom",
		data () {
			return {
				statusColor:{
					'1':'bluefont',//审核通过
					'2':'orangefont',//审核中
					'3':'redfont', //审核失败
					'4':'greenfont' //未认证
				}
			};
		},
		methods:{
			navshopDetail:function(suid){
				if(this.shoptype == 3){ //待处理门店详情暂时屏蔽
					return ;
				}
				uni.navigateTo({
					url: '../../view/shopdetail/shopdetail?suid='+suid+'&type='+this.shoptype+'&status='+this.status,
					success:function(res){
						console.log(res)
					},
					fail:function(res){
						console.log(res)
					}
				})
			},
			//跳转到商户认证功能
			async disMerchantver(item){
				if(this.$store.state.merchantver.categorys == '' || this.$store.state.merchantver.banks == ''){
					let baseinfo = await getbaseinfo({id:1});
					if(baseinfo.code == 0){
						this.$store.state.merchantver.categorys = baseinfo.data.categorys;
						this.$store.state.merchantver.banks = baseinfo.data.banks;
					}else{
						uni.showToast({
							title:baseinfo.msg
						});
						return ;
					}
				}
				// item.assist_url = item.assist_url.replace('https','http')
				getAuthinfo({url:item.assist_url}).then((res) => {
					console.log(res)
					if(res.code == 0){
						this.$store.state.merchantver.uid = res.data.uid;
						this.$store.state.merchantver.suid = res.data.suid;
						
						if(res.data.step == '5'){ 
							if(res.data.is_reject == '0'){ //跳到第三步选择店铺类型
								uni.navigateTo({
									url: `/view/merchantver/merchantver?uid=${res.data.uid}&first_shop=${res.data.first_shop}&is_reject=${res.data.is_reject}&step=${res.data.step}`
								});
							}else{
								uni.navigateTo({ //跳到第三步店铺认证
									url: `/view/merchantverShop/merchantverShop?uid=${res.data.uid}&first_shop=${res.data.first_shop}&is_reject=${res.data.is_reject}&step=${res.data.step}`
								});
							}
						}else{//跳到第二步
							uni.navigateTo({
								url: `/view/merchantver/merchantver?uid=${res.data.uid}&first_shop=${res.data.first_shop}&is_reject=${res.data.is_reject}&step=${res.data.step}`
							});
						}
					}else{
						uni.showToast({
							icon:'none',
							title:res.msg
						})
					}
				}).catch((e) => {
					console.log(e)
				})
			},
			//拨打电话
			makePhone:function(phone){
				cm.makePhoneCall({
					phone:phone
				});
			},
			//零售协助报件--分类信息
			getbaseinfoFun:function(){
				let that = this;
				getbaseinfo({
					id:1
				}).then((res) => {
					console.log(res)
					if(res.code == 0){
						that.$store.state.merchantver.categorys = res.data.categorys;
						that.$store.state.merchantver.banks = res.data.banks;
					}
				}).catch((e) => {
					console.log(e);
				})
			}
		},
		props: {
			shoplistArr:"",
			shoptype:"",
			status:""
		}
	}
</script>

<style lang="scss" scoped>
	input{
		font-size: $uni-font-size-base !important;
		color: $uni-text-color-grey;
	}
	.shoplist{
		.conList_item{
			margin: 20rpx 30rpx 20rpx 30rpx;
			padding: 30rpx;
			box-shadow: 0 0rpx 30rpx rgba(0, 0, 0, 0.06);
			border-radius: $uni-border-radius-base;
			.conList_title{
				border-bottom: 1rpx #E5E5E5 solid;
				.title_name{
					color: $uni-text-color;
					font-size: $uni-font-size-lg;
					font-weight: bold;
					.title_size{
						float: right;
						font-weight: normal;
						font-size: $uni-font-size-base;
						&.red{
							color: #F94441;
						}
						&.blue{
							color: #007AFF;
						}
					}
				}
			}
			.title_id{
				display: flex;
				justify-content: start;
				color: $uni-text-color-grey;
				font-size: $uni-font-size-base;
				padding: 10rpx 0 20rpx 0;
				view{
					width: 40%;
				}
				.title_id_uid{
					display: flex;
					input{
						font-size: $uni-font-size-base;
					}
				}
			}
			.conList_detail{
				padding-top: 15rpx;
				&.conList_detail_waimai{
					padding: 0;
				}
				.conList_info{
					padding: 15rpx 0;
					font-size: $uni-font-size-lg;
					display: flex;
					justify-content: flex-start;
					.info_title{
						color: $uni-text-color-grey;
						width: 25%;
					}
					.info_Text{
						width: 75%;
					}
					.info_tag{
						width: 145rpx;
						height: 40rpx;
						line-height: 40rpx;
						text-align: center;
						font-size: $uni-font-size-sm;
						background-color: rgba($color: #007AFF, $alpha: 0.2);
						color: #007AFF;
						border-radius: $uni-border-radius-sm;
						margin-right: 20rpx;
					}
					.info_warn{
						font-size: $uni-font-size-sm;
						color: #F94441;
						background: rgba(249, 68, 65, 0.1);
						padding-left: 10rpx;
					}
					.info_eve_phone{
						color: #007AFF;
						text-decoration: underline;
					}
					&.conList_info_btn{
						display: flex;
						width: 100%;
						justify-content: flex-end;
						border-top: 1rpx solid #E5E5E5;
						button{
							border-radius: 100rpx;
							font-size: $uni-font-size-base;
						}
					}
				}
			}
		}
	}
</style>
